﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Peekaboo2008.dao;
using CrystalDecisions.CrystalReports.Engine;

namespace Peekaboo2008.view
{
    public partial class FormReportViewerHangTonDuoiDinhMuc : Form
    {
        public FormReportViewerHangTonDuoiDinhMuc()
        {
            InitializeComponent();
        }

        public FormReportViewerHangTonDuoiDinhMuc(String chiNhanh, String ngayXem)
        {
            InitializeComponent();
            LoadReport(chiNhanh, ngayXem);
        }

        /**/
        // Dua id cua chi nhanh va ngay xem bao cao de load thong tin can xem
        /**/

        public void LoadReport(String chiNhanh, String ngayXem)
        {
            DataTable dataTable = ReportDAO.HangTonDuoiDinhMuc(chiNhanh, ngayXem);
            if (dataTable.Rows.Count == 0)
            {
                this.Dispose();
            }
            else
            {
                ReportDocument rdmReportDocument = new ReportDocument();
                // load crystal report vao report document        
                rdmReportDocument.Load("../../report/CrystalReportHangTonDuoiDinhMuc.rpt");
                rdmReportDocument.SetDataSource(dataTable);
                crvReportViewer.ReportSource = rdmReportDocument;
                crvReportViewer.Visible = true;
                crvReportViewer.Refresh();
            }
        }
    }
}
